(function ($) {
	operModeSetup()
	
	function scoreTextTapped(){
		var textDom = this
		removeActive()
		var liDom = textDom.parentNode.parentNode
		currLiId = liDom.id
		liDom.classList.add('dhc-active')
		liDom.classList.add('text-active')
		opBoard.showDHCKeyboard();
		mui('#wrapper').scroll().reLayout();
		var view = document.body.querySelector('.multiPopover .mui-table-view')
		var oldActive = view.querySelector('.dhc-active')
		if (oldActive) {
			oldActive.classList.remove('dhc-active')
		}
		var index = parseInt(liDom.id)
		scrollToNewActiveScorLi(liDom);
		var score = paperData['SubItems'][index]['ItemScore']
		if (score == '') {
			return
		}
		var newActive = view.querySelector('li[data-key="'+score+'"]')
		newActive.classList.add('dhc-active')
		
	}

	function computeScore() {
		var items = paperData['SubItems']
		var realScore = 0;
		var scoreArr = [0, 0];
		for(var i = 0; i < items.length; i++) {
			var itemDict = items[i];
			if(itemDict['HasChild'] == '1') {
				continue;
			}
			if (itemDict['ItemScore'] == '√') {
				scoreArr[0] += 1;
			} else if(itemDict['ItemScore'] == '×') {
				scoreArr[1] += 1;
			}
		}
		var count = scoreArr[0] + scoreArr[1];
		if(count == 0) {
			realScore = '100%';
		} else {
			realScore = (100 * scoreArr[0] / count) + '%';
		}
		realScore = keepTwoDecimalPlaces(realScore); //--公共方法
		mui('#totalScore')[0].innerText = realScore;
		checkScore = realScore
	}
	function operModeSetup(){
		mui('#scroll .scoreText').each(function (index,element) {
			element.addEventListener('tap',scoreTextTapped)
		})
		if (!opBoard ) {
			var checkMenu = "是」√」el-icon-circle-check「否」×」el-icon-circle-close「不适用」-」el-icon-warning-outline"
			opBoard = new mui.DHCSelectBoard('scroll','',OperaMode,checkMenu,function(type,newScore) {
				var activeLi = mui('#scroll li.dhc-active')[0];
				if(!activeLi) {
					hideScoringPopover()
					return;
				}
				var rowIndex = parseInt(activeLi.id)
				if (type == 'add') {
					activeLi.querySelector('.scoreText').innerText = newScore
					paperData['SubItems'][rowIndex]['ItemScore']=newScore
					choseNextScoreText()
					computeScore()
				}else if (type == 'remark') {
					activeLi.classList.remove('dhc-active')
					mui.trigger(activeLi.querySelector('input'),'tap')
				}else if (type == 'last') {
					choseLastScoreText();	
				}else if (type == 'next') {
					choseNextScoreText();
				}else if (type == 'close') {
					hideScoringPopover();
					currLiId = ''
				}
			});	
			//opBoard.openDHCKeyboardDrag();
		}
	}
})(mui)